#pragma once
#include <iostream>
using namespace std;
class Vehicle {
public:
	Vehicle() {
		cout << "Vehicle constructor..." << endl;
	}
	~Vehicle() {
		cout << "Vehicle destructor..." << endl;
	}
	virtual void display() const = 0;
	static Vehicle* createCar();
	static Vehicle* createTruck();
	static Vehicle* createBoat();
};

class Car :public Vehicle {
public:
	Car():Vehicle(){ 
		cout << "Car constructor..." << endl; 
	}
	~Car() {
		cout << "Car destructor..." << endl;
	}
	void display()const
	{
		cout << "This is a car!" << endl;
	}
};

class Truck :public Vehicle {
public:
	Truck() :Vehicle() {
		cout << "Truck constructor..." << endl;
	}
	~Truck() {
		cout << "Truck destructor..." << endl;
	}
	void display()const
	{
		cout << "This is a truck!" << endl;
	}
};

class Boat :public Vehicle {
public:
	Boat() :Vehicle() {
		cout << "Boat constructor..." << endl;
	}
	~Boat() {
		cout << "Boat destructor..." << endl;
	}
	void display()const
	{
		cout << "This is a boat!" << endl;
	}
};


Vehicle* Vehicle::createCar() { return new Car(); }
Vehicle* Vehicle::createTruck() { return new Truck();}// new Truck(); }
Vehicle* Vehicle::createBoat() { return new Boat();}// new Boat(); }
